package com.groovy

import com.enums.DBType
import com.groovy.DBUtils
import groovy.sql.Sql

def url = "100.69.159.124:4308/eps?useUnicode=true&characterEncoding=utf8";//10.140.161.12:1521:orcl
def schema = "epsopr";
def password = "Gb2442_zj";
Sql db = DBType.MYSQL.getInstance(url, schema, password);


//对String的%重载
StringUtils.useMod()
StringUtils.useTitle()

List<String> tableNames = DBUtils.getTableNames(db, "epf_process_check")

List<DBColumnVO> list = DBUtils.getColumn(db, "eps", "epf_process_check");

list.each {
    def sformat = "private %s %s; // %s"
    def arr = it.columnName.toLowerCase().split('_')
    StringBuilder strColumn = new StringBuilder()
    boolean first = true
    for (String value : arr) {
        if (first) {
            strColumn.append(value.charAt(0))
            first = false
        } else {
            strColumn.append(value.charAt(0).toUpperCase());
        }
        strColumn.append(value.substring(1))
    }
    str = strColumn.toString()
    println sformat % [
            DBType.ORACLE.getJavaTypeName(it.columnType),
            str,
            it.comments
    ]
}



